<?php 
require_once 'include.php';
$cates=getAllcate();
if(!($cates && is_array($cates))){
	//alertMes("不好意思，网站维护中!!!", "http://www.baidu.com");
    echo "<script>alert('网站维护中')</script>";
}

?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>首页</title>
<link type="text/css" rel="stylesheet" href="styles/reset.css">
<link type="text/css" rel="stylesheet" href="styles/main.css">
<link rel="stylesheet" href="styles/mF_fancy.css">
	<script src="js/addFavorite.js"></script>
    <script src="js/myfocus-2.0.1.min.js"></script>
    <script src="js/mF_fancy.js"></script>
    <script type="text/javascript">
        myFocus.set({id:'boxID'})
    </script>
<!--[if IE 6]>
<script type="text/javascript" src="js/DD_belatedPNG_0.0.8a-min.js"></script>
<script type="text/javascript" src="js/ie6Fixpng.js"></script>
<![endif]-->

</head>

<body>
<div class="headerBar">
	<div class="topBar">
		<div class="comWidth">
			<div class="leftArea">
				<a href="#" onclick="AddFavorite(window.location,document.title)" class="collection" >收藏网站</a>
			</div>
			<div class="rightArea">
				欢迎来到松田淘淘乐！
				<?php if($_SESSION['loginFlag']):?>
				<span>欢迎您</span><a href="userHome.php"><?php echo $_SESSION['username'];?></a>
				<a href="doAction.php?act=userOut">[退出]</a>
				<?php else:?>
				<a href="login.php">[登录]</a><a href="reg.php">[免费注册]</a>
				<?php endif;?>
			</div>
		</div>
	</div>
	<div class="logoBar">
		<div class="comWidth">
			<div class="logo fl">
				<a href="#"><img src="images/logo_index.png" alt="松田淘淘乐"></a>
			</div>
			<div class="search_box fl">
				<input type="text" class="search_text fl" id="keywords">
				<a href="javascript:search()"><input type="button" value="搜 索" class="search_btn fr"></a>
			</div>
			<script>
			function search(){
				keywords=document.getElementById('keywords').value;
				window.location='search.php?keywords='+keywords;
			}
			</script>
			<div class="shopCar fr">
				<a href="cart.php" style="color:#FFF"><span class="shopText fl" >购物车</span>
				<span class="shopNum fl"><?php echo getAllCartProNum();?></span></a>
			</div>
		</div>
	</div>
	<div class="navBox">
		<div class="comWidth clearfix">
			<div class="shopClass fl">
				<a href="classify.php" style="color:#FFF"><h3>全部商品分类<i class="shopClass_icon"></i></h3></a>
				<div class="shopClass_show">
					<?php foreach($cates as $cate):?>
					<dl class="shopClass_item">
						<dt><a href="classify.php?cateid=<?php echo $cate['id'];?>&cname=<?php echo $cate['cName'];?>" class="b">
						<?php echo $cate['cName'];?></a> <a href="#" class="b">数码</a> <a href="#" class="aLink">合约机</a></dt>
						<dd><a href="#">智能手表</a> <a href="#">手环</a> <a href="#">智能设备</a></dd>
					</dl>
					<?php endforeach;?>
				</div>
			</div>
			<ul class="nav fl">
				<?php foreach($cates as $cate):?>
				<li><a href="classify.php?cateid=<?php echo $cate['id'];?>&cname=<?php echo $cate['cName'];?>"><?php echo $cate['cName'];?></a></li>
				<?php endforeach;?>
				<li><a href="about.php">关于我们</a></li>
			</ul>
		</div>
	</div>
</div>
<!--banner开始-->
<div class="banner comWidth clearfix">
    <div id="boxID" class="banner banner_bar banner_big"><!--焦点图盒子-->
    <div class="pic"><!--内容列表(li数目可随意增减)-->
        <ul>
            <li><a href="#"><img src="images/banner/school_banner.jpg"  /></a></li>
            <li><a href="#"><img src="images/banner/banner_01.jpg"  /></a></li>
            <li><a href="#"><img src="images/banner/banner_03.jpg"  /></a></li>
            <li><a href="#"><img src="images/banner/banner_04.jpg"  /></a></li>
        </ul>
    </div>
</div>
</div>
<!--banner结束-->
<?php foreach($cates as $cate):?>
<div class="shopTit comWidth">
	<span class="icon"></span><h3><?php echo $cate['cName'];?></h3>
	<a href="#" class="more">更多&gt;&gt;</a>
</div>
<div class="shopList comWidth clearfix">
	<div class="leftArea">
		<div class="banner_bar banner_sm">
			<ul class="imgBox">
				<li><a href="#"><img src="images/banner/banner_sm_01.jpg" alt="banner"></a></li>
				<li><a href="#"><img src="images/banner/banner_sm_02.jpg" alt="banner"></a></li>
			</ul>
			<div class="imgNum">
				<a href="#" class="active"></a><a href="#"></a><a href="#"></a><a href="#"></a>
			</div>
		</div>
	</div>
	<div class="rightArea">
		<div class="shopList_top clearfix">
		<?php 
			$pros=getProsByCid($cate['id']);
			if($pros &&is_array($pros)):
			foreach($pros as $pro):
			$proImg=getProImgById($pro['id']);
		?>
			<div class="shop_item">
				<div class="shop_img">
					<a href="proDetails.php?id=<?php echo $pro['id'];?>" target="_blank"><img height="200" width="187" src="image_220/<?php echo $proImg['albumPath'];?>" alt=""></a>
				</div>
				<h4><?php echo $pro['pName'];?></h4>
				<p><?php echo $pro['iPrice'];?>元</p>
			</div>
			<?php 
			endforeach;
			endif;
			?>
			
		</div>
		<div class="shopList_sm clearfix">
		<?php 
			$prosSmall=getSmallProsByCid($cate['id']);
			if($prosSmall &&is_array($prosSmall)):
			foreach($prosSmall as $proSmall):
			$proSmallImg=getProImgById($proSmall['id']);
		?>
			<div class="shopItem_sm">
				<div class="shopItem_smImg">
					<a href="proDetails.php?id=<?php echo $proSmall['id'];?>" target="_blank"><img width="95" height="95" src="image_220/<?php echo $proSmallImg['albumPath'];?>" alt=""></a>
				</div>
				<div class="shopItem_text">
					<p><?php echo $proSmall['pName'];?></p>
					<h3>￥<?php echo $proSmall['iPrice'];?>	</h3>
				</div>
			</div>
			<?php 
			endforeach;
			endif;
			?>
		</div>
	</div>
</div>
<?php endforeach;?>
<div class="hr_25"></div>
<?php include('footer.php');?>
</body>
</html>
